public class booleanSchedule {
        
        private final int numSlots = 56;

        private boolean schedule[] = new boolean[numSlots];
        
        public booleanSchedule()
        {
                for (int count=0; count < numSlots; count++)
                {
                        schedule[count] = false;
                }
        }
        
        public boolean getAvailable(int slot)
        {
                return schedule[slot];
        }
        public void setAvailable(int slot)
        {
                schedule[slot] = true;
        }
        public void setUnavailable(int slot)
        {
                schedule[slot] = false;
        }
        public void setAvailableByRange(int startSlot, int endSlot){
        	for(int i=startSlot; i<endSlot;i++){
        		schedule[i] = true;
        	}
        }
        public void setUnavailableByRange(int startSlot, int endSlot){
        	for(int i=startSlot; i<endSlot;i++){
        		schedule[i] = false;
        	}
        }
        public void setMilTimeSchedUnavailable(milTimeSchedule m, int startTime, int endTime)
        {
        	milTimeSchedule temp = new milTimeSchedule();
        	temp = m;
        	int startTimeSlot;
        	int endTimeSlot;
        	startTimeSlot = temp.milTimeToSlot(startTime);
        	endTimeSlot = temp.milTimeToSlot(endTime);
        	
        	for(int i=startTimeSlot; i <endTimeSlot; i++){
        		schedule[i] = false;
        	}
       }
	//Make sure to put check in to keep start time and end time valid
	
	//creates boolSchedule for one day based on milTimeSchedule
	public void generateSchedule(milTimeSchedule newSchedule)
	{
		int slotCount = newSchedule.getNumSlots();
		//loops through each set slot, one created each time .setAvailable() is called
		for (int i=0;i<slotCount;i++){					
			int startTime = newSchedule.getStart(i);			
			int endTime = newSchedule.getEnd(i);
			int startMin = newSchedule.convertToMin(startTime);
			int endMin = newSchedule.convertToMin(endTime);
			//System.out.println("generateSchedule startTime = " +startTime + " endtime = " + endTime + " start Min = " + startMin + " endMin = " + endMin);
			for (int count = startMin/15; count<endMin/15; count++){
				schedule[count] = true;
			}
		}
	}
	public int convertSlotToMil(int slot){
		int startTime = (slot*15)+480;
		int startMin = startTime%60;
		int startTimeHour = (startTime-startMin)/60;
		startTimeHour = startTimeHour*100;
		startTime = startTimeHour + startMin;
		return startTime;
	}
	public milTimeSchedule getMilTimeSchedule(int newMinMeetTime)
	{
		int index = 0;
		int startTime, endTime, timeDiff;
		int minMeetTime = newMinMeetTime;
                milTimeSchedule m = new milTimeSchedule();
                while(index<numSlots){
                
                       
                        while (index < numSlots && schedule[index] == false)
                        {
                                index++;
                        }
                        
                        if (index >= numSlots) return m;
                        
                        startTime = convertSlotToMil(index);
                        
                        while(index < numSlots && schedule[index] == true)
                        {
                                index++;
                        }
                        
                        if (index >= numSlots)
                        {
                                endTime = convertSlotToMil(numSlots);
                        }
                        else
                        {
                           endTime = convertSlotToMil(index);
                        }
                        //System.out.println("end time is " + endTime);
			timeDiff = m.convertToMin(endTime) - m.convertToMin(startTime);
			
			if(timeDiff>=minMeetTime){
				m.setAvailable(startTime, endTime);
			}else{
				System.out.println(timeDiff + "less than min meeting time");
			}
		}
		return m;

        }
	//Defaults minMeetTime to 30
	public milTimeSchedule getMilTimeSchedule(){
		return getMilTimeSchedule(30);
	}
        
}